import request from '@/utils/request'

export function formatter(id,selectData) {			//格式化下拉列表
	let word = '';
	if(id == null){
		word = '';
	}else{
		selectData.forEach(item =>{
			if(item.value == id.toString()){			
				word = item.label;
			}
		})
	}
	return word;
}		

export function register(postData){                  //注册
	return request({
		url: '/base/register',
		header: {'Content-Type':'application/x-www-form-urlencoded;charset=UTF-8'},
		method:'post',
		data:JSON.stringify(postData),
	})
}

export function busInfo(id){                  //获取商家基本信息
	let busId = parseInt(id)
	return request({
		url: '/bus/info',
		header: {'Content-Type':'application/json;charset=UTF-8'},
		method:'get',
		params: {busId},
	})
}

export function busUpdate(postData){		//更新商家信息
	return request({
		url: '/bus/update',
		headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
	})
}

export function accountInfo(){                  //获取商家基本信息
	return request({
		url: '/account/info',
		header: {'Content-Type':'application/json;charset=UTF-8'},
		method:'get',
	})
}

export function adType(){                  //广告分类
	return request({
		url: '/ad/adType',
		header: {'Content-Type':'application/json;charset=UTF-8'},
		method:'get',
		params:{},
	})
}

export function adPage(postData) {			//广告设置管理列表
  	return request({
    	url: '/ad/page',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function adEdit(postData) {			//广告编辑
  	return request({
    	url: '/ad/edit',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function adRelease(postData) {			//广告发布
  	return request({
    	url: '/ad/release',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function adInsert(postData) {		//广告设置管理新增
  	return request({
    	url: '/ad/insert',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function taskPage(postData) {		//广告分页列表
  	return request({
    	url: '/task/page',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function taskVerify(postData) {		//广告审核
  	return request({
    	url: '/task/verify',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function uploadImage(postData) {		//上传图片
  	return request({
    	url: '/upload/uploadImage',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

/*
 资金管理
 * */
export function payUnifiedOrder(postData) {		//微信充值
  	return request({
    	url: '/pay/unifiedOrder',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function payRechargeRecord(postData) {		//充值记录
  	return request({
    	url: '/account/rechargeRecord',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function payQueryOrder(outTradeNo) {		//查询支付状态
  	return request({
    	url: '/pay/queryOrder',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'get',
    	params:{outTradeNo},
  	})
}

export function accountIsAlipay() {		//判断是否绑定支付宝
  	return request({
    	url: '/account/isAlipay',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'get',
  	})
}

export function accountBindingAlipay(postData) {		//绑定支付宝
  	return request({
    	url: '/account/bindingAlipay',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function uploadSendCode() {		//绑定支付宝发送短信
  	return request({
    	url: '/upload/sendCode',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
  	})
}

export function paySendRedpack(postData) {		//提现
  	return request({
    	url: '/pay/sendRedpack',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

export function accountWithdrawalsRecord(postData) {		//提现
  	return request({
    	url: '/account/withdrawalsRecord',
    	headers:{'Content-Type':'application/json;charset=UTF-8'},
   		method: 'post',
    	data:JSON.stringify(postData),
  	})
}

var typeSelect = [{ 					//广告类型
					value: 0,
					label: '文字'
				}, {
					value: 1,
					label: '图片'
				}, {
					value: 2,
					label: '视频'
				}/*, {
					value: 3,
					label: '文字+图片'
				}, {
					value: 4,
					label: '文字+视频'
				}*/]

export {typeSelect}
export default{
	
}

